import Vue from 'vue';
import { Toast } from 'vant';

Vue.use(Toast);

export function warningMessage(title, duration = 2000) {
  Toast({
    message: title,
    duration:duration
  });
}
export function successMessage(title,func, duration = 1000) {
  Toast({
    message: title,
    type: 'success',
    duration:duration,
    onClose:func
  });
}
export function errorMessage(title, duration = 2000) {
  Toast({
    message: title,
    type: 'fail',
    duration:duration
  });
}

// 根据路由名字跳转
export const linkName = (obj,name,query={})=>{
  obj.$router.push({name,query})
}

// 根据路由名字打开新页面
export const linkOpen = function(obj,name,query={}){
  let routeData = obj.$router.resolve({name:name,query:query})
  window.open(routeData.href, '_blank');
}